package com.yuanchu.media.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.yuanchu.media.dto.EditFileParamsDto;
import com.yuanchu.media.dto.FileIdsDto;
import com.yuanchu.media.dto.FileQueryParams;
import com.yuanchu.media.dto.PageResult;
import com.yuanchu.media.dto.UploadFileParamsDto;
import com.yuanchu.media.entity.YoshopUploadFileEntity;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 文件库记录表
 *
 * @author adan
 * @email 2028038953@gmail.com
 * @date 2023-12-19 20:57:21
 */
public interface YoshopUploadFileService extends IService<YoshopUploadFileEntity> {


    /**
     * 查询文件列表
     * @param params
     * @return
     */
    PageResult queryFiles(FileQueryParams params);

    /**
     * 编辑文件
     * @param params
     * @return
     */
    boolean editFile(EditFileParamsDto params);

    /**
     * 删除文件
     * @param params
     * @return
     */
    boolean deleteFiles(FileIdsDto params);

    /**
     * 根据图片/视频id获取文件信息
     * @param imageId
     * @return
     */
    YoshopUploadFileEntity getUploadFileById(Integer imageId);

    /**
     * @description 上传文件的通用接口
     * @param uploadFileParamsDto 文件信息
     * @param bytes               文件字节数组
     * @param folder              桶下边的子目录
     * @param objectName          对象名称
     * @return com.xuecheng.media.model.dto.UploadFileResultDto
     */
    YoshopUploadFileEntity uploadFile(Integer uploaderId, UploadFileParamsDto uploadFileParamsDto, byte[] bytes, String folder, String objectName);

    /**
     * @param file
     * @param userId
     * @param channel
     * @return com.xuecheng.media.model.dto.UploadFileResultDto
     * @description 上传用户端文件的通用接口
     */
    YoshopUploadFileEntity uploadFileEntity(MultipartFile file, Integer userId, Integer groupId, int channel);


    /**
     * 根据文件id获取文件信息
     * @param fileIds
     * @return
     */
    List<YoshopUploadFileEntity> getUploadFileByIds(List<Integer> fileIds);



    YoshopUploadFileEntity uploadFileToMinio(String bucket, UploadFileParamsDto uploadFileParamsDto, String objectName, String fileMD5, String fileName);

    YoshopUploadFileEntity checkFile(String fileMd5, Integer uploaderId);
}

